//
//  GLChartsCell.m
//  QAQ打飞机
//
//  Created by admin on 15/9/9.
//  Copyright (c) 2015年 gl. All rights reserved.
//

#import "GLChartsCell.h"


@implementation GLChartsCell
-(id)initWithFrame:(CGRect)frame image:( GLImageResource *)image
{
    self=[super initWithFrame:frame];
    if (self!=nil) {
        
        [self setImage:image.scoreimage];
        //添加文本
        [self loadLabelWithFrame:frame];
        //按钮
        [self loadButtonWithFrame:frame];
    }
    return self;
}
#pragma mark -私有方法
#pragma mark 添加按钮
-(void)loadButtonWithFrame:(CGRect)frame
{
    //退出游戏按钮
    _exitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CGFloat w = (frame.size.width - 60)/2.0f;
    CGFloat h = 70;
    CGFloat x = 40;
    CGFloat y = frame.size.height - h + 30;
    [_exitBtn setFrame:CGRectMake(x, y, w, h)];
    [_exitBtn setTitle:@"退出游戏" forState:UIControlStateNormal];
    [_exitBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    //[_exitBtn setBackgroundImage:[UIImage imageNamed:@"images.bundle/btn_an_click.png"] forState:UIControlStateNormal];
    
    //再玩一局按钮
    _playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CGFloat x1 = x + w + 20;
    [_playBtn setFrame:CGRectMake(x1, y, w, h)];
    [_playBtn setTitle:@"重新开始" forState:UIControlStateNormal];
    [_playBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [_playBtn setTag:1];
   // [_playBtn setBackgroundImage:[UIImage imageNamed:@"images.bundle/btn_an_click.png"] forState:UIControlStateNormal];
}

#pragma mark 添加文本
-(void)loadLabelWithFrame:(CGRect)frame
{
    //用户名文本
    NSMutableArray *nameLabel = [NSMutableArray array];
    for (int i = 0; i <8; i++)
    {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(frame.size.width/3, (frame.size.height/10)*(i+1), frame.size.width/3, frame.size.height/10)];
        [label setTextColor:[UIColor orangeColor]];
        [label setText:@"空"];
        
        [self addSubview:label];
        
        [nameLabel addObject:label];
    }
    _nameLabel = nameLabel;
    
    //分数文本
    NSMutableArray *scoreLabel = [NSMutableArray array];
    for (int i = 0; i < 8 ; i++)
    {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(2*frame.size.width/3, (frame.size.height/10)*(i+1), frame.size.width/3, frame.size.height/10)];
        
        [label setTextColor:[UIColor orangeColor]];
        [label setText:@"空"];
        [self addSubview:label];
        
        [scoreLabel addObject:label];
    }
     _scoreLabel= scoreLabel;
    
    //标题文本
    for (int i = 0; i < 8; i++)
    {
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, (frame.size.height/10)*(i+1), frame.size.width/3, frame.size.height/10)];
        [label setTextColor:[UIColor orangeColor]];
        [label setText:[NSString stringWithFormat:@"%d",i+1]];
        [self addSubview:label];
    }
}
@end
